using Andromeda.Global.Business.DataObject;
using ForgeIt.Dal.dbo;
using System;

using System.Collections.Generic;
using System.Linq;
using Andromeda.Global.Data;

namespace ForgeIt.Business.Stub
{
	public abstract class CustomerStub : DataObjectModelBase
	{
		#region private fields


		private DBCustomer foDBCustomer;

        private Entity localIdEntity;


		#endregion private fields
    
		#region public constructors

		protected CustomerStub()
			: this(new DBCustomer())
		{
		}

        protected CustomerStub(Entity foIdEntity)
          :this()
        {
            SetIdEntity(foIdEntity);
        }

		#endregion public constructors
    

		#region internal constructors

		internal CustomerStub(DBCustomer foDBCustomer)
		{

			this.foDBCustomer = foDBCustomer;

		}

		#endregion internal constructors
  

		#region protected datasource properties
		

		internal DBCustomer DB_DBCustomer
		{
			get { return foDBCustomer ?? (foDBCustomer = new DBCustomer()); }
		}

		
		public override DataConnectorCollection DataObjects
		{
			get
			{
				return new DataConnectorCollection { foDBCustomer } ;
			}
		}

		

		/// 
		///
		/// 
		public int IdCustomer
		{
			get { return DB_DBCustomer.IdCustomer; }

		}

		/// 
		///
		/// 
		public int IdEntity
		{
			get { return DB_DBCustomer.IdEntity; }

			set { DB_DBCustomer.IdEntity = value; }

		}

		/// 
		///
		/// 
		public int IdCountry
		{
			get { return DB_DBCustomer.IdCountry; }

			set { DB_DBCustomer.IdCountry = value; }

		}

		/// 
		///
		/// 
		public string FIN
		{
			get { return DB_DBCustomer.FIN; }

			set { DB_DBCustomer.FIN = value; }

		}

		/// 
		///
		/// 
		public System.DateTime FoundingDate
		{
			get { return DB_DBCustomer.FoundingDate; }

			set { DB_DBCustomer.FoundingDate = value; }

		}

		#endregion protected datasource properties
    
		#region protected datasource foreign key properties
    

		///<summary>
		/// Getter method for obtainin a foreign key <see cref="Entity"/> object related to this object
		///</summary>
		public virtual Entity GetIdEntity()
		{
          return localIdEntity ?? (localIdEntity = new Entity(foDBCustomer.GetFK_IdEntity()));
		}
    

  		///<summary>
  		/// Setter method for linking this object to a foreign key object
  		///</summary>
  		///<param name="item">The <see cref="Entity"/> object to which we want to link our IdEntity</param>
  		public virtual void SetIdEntity(Entity item)
        {
          foDBCustomer.SetFK_IdEntity(item.DB_DBEntity);
          localIdEntity = new Entity(foDBCustomer.GetFK_IdEntity());
        }

  
		#endregion protected datasource foreign key properties
    
		#region protected datasource external key properties
    

  
		#endregion protected datasource external key properties
    
		#region properties
    

		#endregion properties
    
		#region methods methods

		#endregion methods

        #region Static Factories

        public static Customer GetCustomer(int foIdCustomer)
        {
          return new Customer(DBCustomer.GetEntity(foIdCustomer));
        }
  
        public static IEnumerable<Customer> ListCustomer()
        {
            return (from DBCustomer entity in DBCustomer.ListEntity() select new Customer(entity));
        }
        
  
        public static IEnumerable<Customer> ListCustomer(object foIdCustomer, object foIdEntity, object foIdCountry, object foFIN, object foFoundingDate)
        {
            return (from DBCustomer entity in DBCustomer.ListEntity(foIdCustomer, foIdEntity, foIdCountry, foFIN, foFoundingDate) select new Customer(entity));
        }
        
        #endregion Static List Methods

	
  }
}